import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import cesium from 'vite-plugin-cesium'

export default defineConfig({
  base: '/',
  plugins: [
    vue(),
    cesium()
  ],
  publicDir: 'public',
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
      crypto: 'crypto-browserify'
    }
  },
  server: {
    port: 8081,
    proxy: {
      '/api': {
        target: 'http://112.124.48.83:6099',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
  define: {
    CESIUM_BASE_URL: JSON.stringify('./')
  },
  build: {
    rollupOptions: {
      output: {
        manualChunks: {
          cesium: ['cesium']
        }
      }
    }
  }
})